package com.kantboot.functional.pay.order.controller;

import com.kantboot.functional.pay.order.module.entity.FunctionalPayOrder;
import com.kantboot.functional.pay.order.service.IFunctionalPayOrderService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pay-order/order")
public class PayOrderController {

    @Resource
    private IFunctionalPayOrderService service;

    /**
     * 生成支付订单
     */
    @RequestMapping("/generatePayOrder")
    public RestResult<FunctionalPayOrder> generatePayOrder(@RequestBody FunctionalPayOrder payOrder){
        return RestResult.success(service.generatePayOrder(payOrder), "generateSuccess","生成成功");
    }

    /**
     * 根据id查询支付订单
     */
    @RequestMapping("/getById")
    public RestResult<FunctionalPayOrder> getById(@RequestParam("id") Long id){
        return RestResult.success(service.getById(id), "getSuccess","查询成功");
    }

    /**
     * 检查支付后的处理是否成功
     * checkPaidAfterSuccess
     */
    @RequestMapping("/checkPaidAfterSuccess")
    public RestResult<Boolean> checkPaidAfterSuccess(@RequestParam("orderId") Long orderId){
        return RestResult.success(service.checkPaidAfterSuccess(orderId), "checkSuccess","检查成功");
    }


}
